﻿using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
using GalaSoft.MvvmLight;
using SkiTracker.Model;

namespace SkiTracker.Converter
{
    public class MessageToHorizontalAlignmentConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var message = value as Message;
            if (message == null) return DependencyProperty.UnsetValue;

            if (ViewModelBase.IsInDesignModeStatic)
                return (message.DeviceId == 0)
                       ? HorizontalAlignment.Right
                       : HorizontalAlignment.Left;

            return (message.DeviceId == App.CurrentApp.CurrentDevice.Id)
                       ? HorizontalAlignment.Right
                       : HorizontalAlignment.Left;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
